<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>gethostname</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4>NAME</h4><blockquote>
gethostname - get name of current host
</blockquote><h4>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="unistd.h.html">unistd.h</a>&gt;

int gethostname(char *<I>name</I>, size_t <I>namelen</I>);
</code>
</pre>
</blockquote><h4>DESCRIPTION</h4><blockquote>
The
<i>gethostname()</i>
function returns the standard host name for the current machine.  The
<I>namelen</I> argument specifies the size of the array pointed to by the
<I>name</I> argument.  The returned name is null-terminated, except that if
<I>namelen</I> is an insufficient length to hold the host name, then the
returned name is truncated and it is unspecified whether the returned name is
null-terminated.
<p>
Host names are limited to 255 bytes.
</blockquote><h4>RETURN VALUE</h4><blockquote>
On successful completion, 0 is returned.  Otherwise, -1 is returned.
</blockquote><h4>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4>SEE ALSO</h4><blockquote>
<i><a href="../xsh/gethostid.html">gethostid()</a></i>
(in the <B>XSH</B> specification),
<i><a href="../xsh/uname.html">uname()</a></i>,
<i><a href="../xsh/unistd.h.html">&lt;unistd.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
